home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 343_02 / mainr.c < prev    next >
C/C++ Source or Header  |  1992-04-06  |  4KB  |  132 lines

  1.  
  2.        /***********************************************
  3.        *
  4.        *       file d:\cips\mainr.c
  5.        *
  6.        *       Functions: This file contains
  7.        *          main
  8.        *
  9.        *       Purpose:
  10.        *          This file contains the main calling
  11.        *          routine for a program which rotates an
  12.        *          entire 300x300 image by 90
  13.        *          degrees.
  14.        *
  15.        *       External Calls:
  16.        *          gin.c - get_image_name
  17.        *          numcvrt.c - get_integer
  18.        *                      int_convert
  19.        *          tiff.c - read_tiff_header
  20.        *          rotate.c - rotate_flip_image_array
  21.        *
  22.        *       Modifications:
  23.        *          7 April 1992 - created
  24.        *
  25.        *************************************************/
  26.  
  27. #include "d:\cips\cips.h"
  28.  
  29.  
  30.  
  31. short the_image[ROWS][COLS];
  32. short out_image[ROWS][COLS];
  33.  
  34. main(argc, argv)
  35.    int argc;
  36.    char *argv[];
  37. {
  38.  
  39.    char     name[80], name2[80];
  40.    int      count, length, width;
  41.    struct   tiff_header_struct image_header;
  42.  
  43.    _setvideomode(_TEXTC80); /* MSC 6.0 statements */
  44.    _setbkcolor(1);
  45.    _settextcolor(7);
  46.    _clearscreen(_GCLEARSCREEN);
  47.  
  48.        /***********************************************
  49.        *
  50.        *       Interpret the command line parameters.
  51.        *
  52.        ************************************************/
  53.  
  54.    if(argc < 3 || argc > 3){
  55.     printf(
  56.      "\n"
  57.      "\n usage: mainr in-file out_file "
  58.      "\n");
  59.     exit(0);
  60.    }
  61.  
  62.    strcpy(name, argv[1]);
  63.    strcpy(name2, argv[2]);
  64.  
  65.    if(does_not_exist(name2)){
  66.       printf("\n\n output file does not exist %s", name2);
  67.       read_tiff_header(name, &image_header);
  68.       round_off_image_size(&image_header,
  69.                            &length, &width);
  70.       image_header.image_length = length*ROWS;
  71.       image_header.image_width  = width*COLS;
  72.       create_allocate_tiff_file(name2, &image_header,
  73.                                 out_image);
  74.    }  /* ends if does_not_exist */
  75.  
  76.        /***********************************************
  77.        *
  78.        *   Read, rotate, and write each ROWSxCOLS array
  79.        *   in the input image.  Write them to the new
  80.        *   locations in the output image.
  81.        *
  82.        ************************************************/
  83.  
  84.    count = 1;
  85.  
  86.    printf(" %d", count++);
  87.    rotate_flip_image_array(name, name2, the_image,
  88.                       out_image, 1, 1, 101, 101,
  89.                       1, 201, 101, 301, 1);
  90.  
  91.    printf(" %d", count++);
  92.    rotate_flip_image_array(name, name2, the_image,
  93.                       out_image, 1, 101, 101, 201,
  94.                       101, 201, 201, 301, 1);
  95.  
  96.    printf(" %d", count++);
  97.    rotate_flip_image_array(name, name2, the_image,
  98.                       out_image, 1, 201, 101, 301,
  99.                       201, 201, 301, 301, 1);
  100.  
  101.    printf(" %d", count++);
  102.    rotate_flip_image_array(name, name2, the_image,
  103.                       out_image, 101, 1, 201, 101,
  104.                       1, 101, 101, 201, 1);
  105.  
  106.    printf(" %d", count++);
  107.    rotate_flip_image_array(name, name2, the_image,
  108.                       out_image, 101, 101, 201, 201,
  109.                       101, 101, 201, 201, 1);
  110.  
  111.    printf(" %d", count++);
  112.    rotate_flip_image_array(name, name2, the_image,
  113.                       out_image, 101, 201, 201, 301,
  114.                       201, 101, 301, 201, 1);
  115.  
  116.    printf(" %d", count++);
  117.    rotate_flip_image_array(name, name2, the_image,
  118.                       out_image, 201, 1, 301, 101,
  119.                       1, 1, 101, 101, 1);
  120.  
  121.    printf(" %d", count++);
  122.    rotate_flip_image_array(name, name2, the_image,
  123.                       out_image, 201, 101, 301, 201,
  124.                       101, 1, 201, 101, 1);
  125.  
  126.    printf(" %d", count++);
  127.    rotate_flip_image_array(name, name2, the_image,
  128.                       out_image, 201, 201, 301, 301,
  129.                       201, 1, 301, 101, 1);
  130.  
  131. }  /* ends main  */
  132.